<?php
	session_start();
	$dic = "QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890";
	$code = "";
	$arr = str_split($dic);
	$len = count($arr)-1;
	for($i=0;$i<4;$i++){
		$code.=$arr[rand(1, $len)];
	}
	$_SESSION['verify']=$code;
	header("Content-type:image/jpeg");
	$img = imagecreate(80,30);
	$bg = imagecolorallocate($img, 0, 0, 0);
	$mix = imagecolorallocate($img, 255, 145, 155);
	$pen = imagecolorallocate($img, 255, 255, 255);
	for ($i=0;$i<50;$i++){
		imagesetpixel($img, rand(0, 80), rand(0, 30), $pen);
	}
	for ($i=0;$i<6;$i++){
		imageline($img, rand(0, 80), rand(0, 30),rand(0, 80), rand(0, 30),$mix);
	}
	imagestring($img, 5, 20, 8, $code, $pen);
	imagejpeg($img);
	imagedestroy($img);
?>